package th1701_caphe;

import java.util.Scanner;

public class CaPhe {
	private String ten;
	private String loai;
	private int trongLuong;
	private int giaCa;
	
	//Phuong thuc khoi tao ko tham so
	public CaPhe(){
		
	}
	
	//Phuong thuc khoi tao co tham so
	public CaPhe(String ten, String loai, int trongLuong, int giaCa){
		this.ten = ten;
		this.loai = loai;
		this.trongLuong = trongLuong;
		this.giaCa = giaCa;
	}
	
	//Phuong thuc nhap
	public void nhapCaPhe(){
		Scanner str = new Scanner(System.in);
		
		System.out.println("Vui long nhap ten Ca phe: ");
		this.ten = str.nextLine();
		System.out.println("Vui long nhap ten loai Ca phe: ");
		this.loai = str.nextLine();
		System.out.println("Vui long nhap trong luong: ");
		this.trongLuong = str.nextInt();
		System.out.println("Vui long nhap gia ca: ");
		this.giaCa = str.nextInt();
	}
	
	//Phuong thuc in thong tin
	public void xuatThongTin(){
		System.out.println("Ten ca phe: " +this.ten);
		System.out.println("Loai ca phe: " +this.loai);
		System.out.println("Trong luong: " +this.trongLuong);
		System.out.println("Gia ca: "+this.giaCa);
	}
	
	//Phuong thuc so sanh ca phe
	public boolean equals(CaPhe q){
		if(q instanceof CaPhe){
			boolean kq1 = this.ten.equalsIgnoreCase(q.ten);
			boolean kq2 = this.loai.equalsIgnoreCase(q.loai);
			boolean kq3 = this.trongLuong == trongLuong;
			boolean kq4 = this.giaCa == giaCa;
			
			return	kq1 && kq2 && kq3 && kq4;
		}
		return false;
	}
	
	//Phuong thuc tinh tien ca phe
	public int tinhTien(){
		return this.giaCa*this.trongLuong;
	}
}
